package cn.duyo.spring.beans.factory.support;

import cn.duyo.spring.core.io.DefaultResourceLoader;
import cn.duyo.spring.core.io.ResourceLoader;

/**
 * bean定义读取器抽象类 (将两个工具: 资源包装加载器、bean定义注册器放进来，避免污染具体实现类)
 * tips: 抽象类基本都是为了避免污染具体子类 (或定义步骤模板), 子类只应关心具体业务功能实现, 抽象类是提供具体实现类的工具"粘合剂"
 *
 * @author du
 */
public abstract class AbstractBeanDefinitionReader implements BeanDefinitionReader {

    private final BeanDefinitionRegistry registry;

    private ResourceLoader resourceLoader;

    public AbstractBeanDefinitionReader(BeanDefinitionRegistry registry) {
        this(registry, new DefaultResourceLoader());
    }

    public AbstractBeanDefinitionReader(BeanDefinitionRegistry registry, ResourceLoader resourceLoader) {
        this.registry = registry;
        this.resourceLoader = resourceLoader;
    }

    @Override
    public BeanDefinitionRegistry getRegistry() {
        return registry;
    }

    @Override
    public ResourceLoader getResourceLoader() {
        return resourceLoader;
    }

}